/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upn.sigemfi.vfi.beans;

import edu.upn.sigemfi.ope.be.Boveda;
import edu.upn.sigemfi.vfi.bc.BovedaDelegate;
import java.util.List;
import javax.faces.model.SelectItem;

/**
 *
 * @author Alex
 */
public class BovedaController {

    private Boveda moneda;
    private BovedaDelegate delegado;

    public BovedaController() {
        delegado = new BovedaDelegate();

    }


       public SelectItem[] getMonedas() {
        SelectItem[] select = null;
        try {
            List<Boveda> lista = delegado.listar();
            if (lista != null) {
                select = new SelectItem[lista.size()+1];
                int i = 0;
                 select[i++] = new SelectItem(null, "<<Seleccione una Boveda");
                for (Boveda m : lista) {
                    select[i++] = new SelectItem(m, m.getCodigo());
                }
            } else {
                select = new SelectItem[1];
                select[0] = new SelectItem(null, "No existen Bovedas");
            }
        } catch (Exception e) {

        select = new SelectItem[1];
        select[0] = new SelectItem(null, "<<Hubo un error>>" + e.getMessage());
        }
        return select;
    }
}
